package com.rendevous.service;

import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.json.simple.parser.ParseException;

import com.rendevous.bean.Task;
import com.rendevous.utils.Constants;

public class ToDoListImpl extends ToDoList {

	public ToDoListImpl() throws IOException, ParseException {
		super();
	}

	@Override
	public String addTask(Task task) {
		String feedback;
		if (dao.createTask(task)) {
			feedback = String.format(Constants.MSG_ADDED, task.getContent());
		} else {
			feedback = Constants.MSG_ADDED_FAILED;
		}
		return feedback;
	}

	@Override
	public String updateTask(long taskId, Task newTask) {
		String feedback;
		newTask.setId(taskId);
		if (dao.updateTask(newTask)) {
			feedback = String.format(Constants.MSG_UPDATED, newTask.getContent());
		} else {
			feedback = Constants.MSG_UPDATED_FAILED;
		}
		return feedback;
	}

	@Override
	public String deleteTask(long taskId) {
		String feedback;
		if (dao.deleteTask(taskId)) {
			feedback = String.format(Constants.MSG_DELETED, taskId);
		} else {
			feedback = Constants.MSG_DELETED_FAILED;
		}
		return feedback;
	}

	@Override
	public String undo() {
		// TODO Auto-generated method stub
		return null;
	}

}
